/**
 * @file ExtraAttr
 * @author  fanxl
 */

import type {FileTypeEnumType, EditorToolsEnumType} from './enum';

export type AnyObject = Record<string | number | symbol, any>;
export type CustomObject = Record<string, any>;

export interface Datasource {
    label: string;
    value: string;
    disabled?: boolean;
}

export interface ColorConfigAttr {
    presetColors: Datasource[];
    allowCustom?: boolean;
}

export interface ExtensionsAttr {
    name: string;
    displayName?: string;
    params?: CustomObject[];
}

export interface BasicExtraAttr {
    tags?: string[];
    initialCount?: number;
    colorConfig?: ColorConfigAttr;
    extensions?: ExtensionsAttr[];
    reactions?: CustomObject;
    miscAttr?: CustomObject;
    hideUrl?: boolean;
    isAlwaysDefaultValue?: boolean;
    format?: string;
    requireInitValue?: boolean;
    remote?: {
        payload?: {[index: string]: string};
        useSource?: {[index: string]: string};
        api?: string;
        searchable?: boolean;
        trigger: string;
    };
    slots?: CustomObject[];
}

export interface EditorConfigAttr {
    tools?: EditorToolsEnumType[];
    allowItalicTag?: boolean;
}

export interface HtmlTagAttributeRules {
    isRequired?: boolean;
    isAllowNoValue?: boolean;
    valueType?: string;
    defaultValue?: string;
}

export interface HtmlTagConfig {
    attributeRules?: HtmlTagAttributeRules;
    requiredAttributes?: string[];
    isAllowNoContent?: boolean;
    isSimpleTag?: boolean;
}

export interface TagListAttr {
    a?: HtmlTagConfig;
    em?: HtmlTagConfig;
}

export interface HtmlExtraAttr extends BasicExtraAttr {
    editorConfig?: EditorConfigAttr;
    tagList?: TagListAttr;
}

export interface ImageExtraAttr extends BasicExtraAttr {
    fileType?: FileTypeEnumType;
    width?: number;
    height?: number;
    ratio?: string;
    maxSize?: number;
    ext?: string;
    minWidth?: number;
    maxWidth?: number;
    minHeight?: number;
    maxHeight?: number;
    ratioList?: string[];
    multiple?: boolean;
    maxCount?: number;
}

export interface VideoExtraAttr extends BasicExtraAttr {
    width?: number;
    height?: number;
    ratio?: string;
    minWidth?: number;
    maxWidth?: number;
    minHeight?: number;
    maxHeight?: number;
    formats?: string[];
    size?: number[];
    duration?: number[];
    ratioList?: string[];
}

export interface AudioExtraAttr extends BasicExtraAttr {
    maxSize?: number;
    ext?: string;
}

export interface ExtraAttr {
    basic: BasicExtraAttr;
    html: HtmlExtraAttr;
    image: ImageExtraAttr;
    video: VideoExtraAttr;
    audio: AudioExtraAttr;
}
